import React from "react";
import { connect } from "react-redux";

const mapStateToProps = (state) => {
  return {
    count: state.count,
    name: state.name,
  };
};

const mapDispatchToProps = (dispatch) => {
  return {
    change(name) {
      dispatch({
        type: "changeName",
        name,
      });
    },
  };
};

const Child = connect(
  mapStateToProps,
  mapDispatchToProps
)((props) => {
  return (
    <div>
      这是child组件 - {props.count} - {props.name} -{" "}
      <button onClick={() => props.change("jerry")}>btn</button>
    </div>
  );
});

export default Child;
